package com.example.reader.service;

import com.example.reader.entity.Book;
import com.example.reader.mapper.BookMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BookService {
    @Autowired
    private BookMapper bookMapper;

    public List<Book> selectHot() {
        return bookMapper.selectHot();
    }

    public List<Book> selectAll(Book book){
        book.setGrounding(true);   // 普通用户只能看到上架的图书
        return bookMapper.selectAll(book);
    }
    public PageInfo<Book> selectPage(Book book,Integer pageNum,  Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Book> list=bookMapper.selectAll(book);
        return PageInfo.of(list);
    }
    public Book selectById(Integer id){
        return bookMapper.selectById(id);
    }



}
